package net.pr06bot.loader;

import java.applet.Applet;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

@SuppressWarnings("serial")
public class BotApplet extends Applet {

	private Applet loader;
	private String jarURL = "http://divine-reality.net/Divine-RealityV11.2.jar";

	public String getJarURL() {
		return jarURL;
	}

	public ClassLoader getClasses() throws MalformedURLException {
		return new URLClassLoader(new URL[] { new URL(getJarURL()) });
	}

	public Applet loadStub() throws Exception {
		System.out.println("Getting main class..");
		Class<?> clientClass = getClasses().loadClass("M");
		loader = (Applet) clientClass.newInstance();
		loader.setStub(new BotStub());
		loader.init();
		loader.start();
		return loader;
	}

}
